#ifndef SOCKET_H
#define SOCKET_H

#include "InetAddress.h"

class Socket {
public:
    Socket(int fd) :
        fd_(fd)
    {
    }

    ~Socket();

    const int getFd() { return fd_; }

    void setReuseAddr(bool on);
    void setReusePort(bool on);
    void setKeepAlive(bool on);

    void bind(InetAddress& addr);

    void listen();

    int accept(InetAddress* peerAddr);

    int read(char* buf, size_t len);

    int write(const char* buf, size_t len);

    void shutdownWrite();

    static int createNonblockSocektOrDie();
private:
    int fd_;
};

#endif